module Display {
	export class DeepthTest extends egret.DisplayObjectContainer{
		private _txInfo:egret.TextField;
		private _heros:Array<egret.Bitmap>=[];

		/**
		 * 构造函数
		 * 监听添加到舞台事件
		 */
		public constructor() {
			super();
			this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this);
		}

		/**
		 * 添加到舞台监听器
		 * 加载图片 
		 * @param evt:Event
		 */
		private onAddedToStage(evt:egret.Event):void{
			var imgLoader:egret.ImageLoader=new egret.ImageLoader;
			imgLoader.once(egret.Event.COMPLETE,this.imgLoaderHandler,this);
			imgLoader.load("resource/hero.png");
		}

		/**
		 * 图片加载监听器
		 * @param evt:Event
		 */
		private imgLoaderHandler(evt:egret.Event):void{
			//添加三个英雄
			var bmd=evt.currentTarget.data;
			var sw:number=this.stage.stageWidth;
			var sh:number=this.stage.stageHeight;
			var left_hero:egret.Bitmap=new egret.Bitmap(bmd);
			left_hero.x=sw/2-left_hero.width*.7;
			var right_hero:egret.Bitmap=new egret.Bitmap(bmd);
			right_hero.x=sw/2-right_hero.width*.3;
			var mid_hero:egret.Bitmap=new egret.Bitmap(bmd);
			mid_hero.x=sw/2-mid_hero.width*.5;
			left_hero.y=right_hero.y=mid_hero.y=sh/2-left_hero.height/2;
			left_hero.touchEnabled=right_hero.touchEnabled=mid_hero.touchEnabled=true;
			left_hero.pixelHitTest=right_hero.pixelHitTest=mid_hero.pixelHitTest=true;
			this.addChild(left_hero);
			this.addChildAt(right_hero,1);
			this.addChildAt(mid_hero,this.numChildren);
			//为三个英雄添加触摸事件
			left_hero.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
				this.setChildIndex(left_hero,this.numChildren-1);
			},this);
			right_hero.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
				this.setChildIndex(right_hero,this.numChildren-1);
			},this);
			mid_hero.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
				this.setChildIndex(mid_hero,this.numChildren-1);
			},this);
			/// 提示信息
			this._txInfo = new egret.TextField;
			this._txInfo.size = 28;
			this._txInfo.textAlign = egret.HorizontalAlign.CENTER;
			this._txInfo.textColor = 0x843900;
			this._txInfo.lineSpacing = 6;
			this._txInfo.multiline = true;
			this._txInfo.text = "点击不同女孩提升到最上层";
			this._txInfo.x = this.stage.stageWidth / 2 - this._txInfo.width / 2;
			this._txInfo.y = 120;
			this.addChild(this._txInfo);
		}
	}
}